<?php

namespace App\Admin\Controllers;

use App\creditcard;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class CreditCardController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\creditcard';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new creditcard());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('CardNo', '信用卡号');

        });

        $grid->column('CardNo', __('信用卡号'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Type', __('卡类型'));
        $grid->column('Bank', __('银行'));
        $grid->column('Belongs', __('所属人'));
        $grid->column('DueDate', __('到期日'));
        $grid->column('SecurityCode', __('安全码'));
        $grid->column('ReservedPhone', __('预留手机'));
        $grid->column('Bill', __('账单日'));
        $grid->column('Remarks1', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks2', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks3', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks4', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks5', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks6', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks7', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks8', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks9', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Remarks10', __('其他备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(creditcard::findOrFail($id));



        $show->field('CardNo', __('信用卡号'));
        $show->field('Type', __('卡类型'));
        $show->field('Bank', __('银行'));
        $show->field('Belongs', __('所属人'));
        $show->field('DueDate', __('到期日'));
        $show->field('SecurityCode', __('安全码'));
        $show->field('ReservedPhone', __('预留手机'));
        $show->field('Bill', __('账单日'));
        $show->field('Remarks1', __('其他备注'));
        $show->field('Remarks2', __('其他备注'));
        $show->field('Remarks3', __('其他备注'));
        $show->field('Remarks4', __('其他备注'));
        $show->field('Remarks5', __('其他备注'));
        $show->field('Remarks6', __('其他备注'));
        $show->field('Remarks7', __('其他备注'));
        $show->field('Remarks8', __('其他备注'));
        $show->field('Remarks9', __('其他备注'));
        $show->field('Remarks10', __('其他备注'));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new creditcard());



        $form->text('CardNo', __('信用卡号'));
        $form->text('Type', __('卡类型'));
        $form->text('Bank', __('银行'));
        $form->text('Belongs', __('所属人'));
        $form->datetime('DueDate', __('到期日'));
        $form->text('SecurityCode', __('安全码'));
        $form->mobile('ReservedPhone', __('预留手机'));
        $form->datetime('Bill', __('账单日'));
        $form->text('Remarks1', __('其他备注'));
        $form->text('Remarks2', __('其他备注'));
        $form->text('Remarks3', __('其他备注'));
        $form->text('Remarks4', __('其他备注'));
        $form->text('Remarks5', __('其他备注'));
        $form->text('Remarks6', __('其他备注'));
        $form->text('Remarks7', __('其他备注'));
        $form->text('Remarks8', __('其他备注'));
        $form->text('Remarks9', __('其他备注'));
        $form->text('Remarks10', __('其他备注'));


        return $form;
    }
}
